Repository navigation
fix(data-objectstack): uploadFile/uploadFiles upload through the storage service presigned flow - #38237
Conversation
…age service's presigned flow The two methods posted to /api/data/<resource>/upload, a route the standard server does not serve (404 ENDPOINT_NOT_FOUND). They now delegate to createObjectStackUploadAdapter: presigned request, byte PUT, completion, with recordId mapped to attachTo (scope attachments). fieldName and metadata, which neither presigned request carries, are refused before any request instead of dropped. Storage refusals reject UPLOAD_ERROR with the server's status and code. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibx7DSQZnugnuX8CpCM
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibx7DSQZnugnuX8CpCM
The dogfood package declares @object-ui/data-objectstack as a dev dependency so the pin resolves the adapter, the dogfood closure builds it, and the dogfood test hash follows adapter changes. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibx7DSQZnugnuX8CpCM
📓 Docs Drift Check
What this run could not see
Coarse fallback — 2 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
…solated project check:test-source-alias asks for one anchored alias per new workspace import, so the upload-route pin is a verdict about the adapter source in the checkout, not about its last build. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibx7DSQZnugnuX8CpCM
|
repo:objectstack#3 · os-tesla · session_01L9qibwSEecrzDjKjbk24r1 L1-a ACCEPT at Face. L1 only, no L2 owed. The 8 files touch no Claim against surface (claim 7236668269, surface additions 7236682186, 7237259964, 7237706727). The surface matches file for file.
Changeset, read sentence by sentence: every bullet matches the code. That covers the three-request flow, sequential Evidence (reports 7237242813, 7237679580, 7238096080).
Checks at this head: 11 skipped · 60 success · 0 pending; Lint & Repo Gates, TypeScript Type Check and Check Changeset green. Nit (not blocking). Out of scope, answered for the seat. |
… server The upload fetch counts a URL as this server only when it is a path with one leading slash or starts with the data source's own origin. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibx7DSQZnugnuX8CpCM
…resolved origins A request counts as this server only when the URL parser resolves it to the server's origin (baseUrl, or the page's origin when baseUrl is empty), under baseUrl's path when it has one. An unreadable server or an unparsable URL is not this server. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibx7DSQZnugnuX8CpCM
|
repo:objectstack#3 · os-tesla · session_01L9qibwSEecrzDjKjbk24r1 L1-a delta: ACCEPT at
Still L1 only: no face has moved. The PR body should stay neutral about the hardening: it states what the check does, with no claim of a prior exposure. |
|
repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU Landing · 2026-11-28T12:57Z · zone
|
Requested by Tesla · project thread
Fixes #38163
Clause-②: no
Metadata-protocol: none
Route taken: (a).
uploadFileanduploadFilesnow upload through the package's own presigned storage adapter,createObjectStackUploadAdapter.recordIdmaps toattachTowith scopeattachments, and the adapter's result maps toFileUploadResult. The declaredDataSourcecontract promises an upload that returns a stored file, and the storage service is the one upload route the standard server serves, so (a) keeps that promise and (b) would not. Two options cannot be mapped:fieldNameandmetadata. Neither presigned request carries them. Those two are refused before any request, in the (b) manner, with an error that names the supported path, so nothing is dropped silently. Neither method sends a request to/api/data/RESOURCE/uploadany more.Why refusing
fieldName/metadatais not a narrowing (Clause-②: nostands): before this PR every call to either method failed. The standard server answers the old route 404ENDPOINT_NOT_FOUND(405 with the version segment), whatever options were passed, so no caller had a working upload that carried those options. This PR removes no working behaviour. A call that always failed now succeeds without the two options, and with them it fails at once with an error that names the supported path, instead of a 404. The public types (DataSource.uploadFile/uploadFiles,FileUploadResult) are unchanged, and no metadata an author writes is affected (Metadata-protocol: none).维护者速读
What changes
ui/packages/data-objectstack/src/index.ts:uploadFiledelegates tocreateObjectStackUploadAdapter, which sendsPOST /api/v1/storage/upload/presigned, the bytePUT, thenPOST /api/v1/storage/upload/complete. The adapter is built per call becauseattachTois one of its construction options. The fetch it uses is built once per data source (storageUploadFetch). That fetch is the injecteduploadTransport(data-objectstack:上传文件和 metadata-client 绕过注入的 fetch,纯令牌会话下被当匿名(接 #37225) #37506), plus the data source'stokenon every request to this server and never on a presigned URL on another origin. The same-origin check compares resolved origins: the URL is resolved againstbaseUrl, or the page's origin whenbaseUrlis empty, and it counts as this server only when the origins match (and, for abaseUrlwith a path, the resolved path lies under it). A server that cannot be read, or a URL that does not parse, is not this server.uploadFilesis N sequential presigned uploads. The first refused file stops the batch, and the rejection'sdetailscarryfailedIndexplus, asuploaded, the files already stored. The files after it are not sent.recordIdmaps toattachTo: { parentObject: resource, parentId: recordId }andscope: 'attachments'. Without it, no scope is sent, so the server default applies, andresourceis not sent.onProgressmaps the adapter's 0 to 1 ratio to 0 to 100, spread across the batch foruploadFiles.fieldNameandmetadatareject withUNSUPPORTED_OPERATIONbefore any request.ObjectStackErrorwithUPLOAD_ERROR, the server's status, anddetails.serverCode. A failure that got no HTTP answer reaches the caller unchanged, as before.ui/packages/data-objectstack/src/upload-adapter.ts: the presign refusal and the byte-PUT refusal now carrystatus(andcode), as the completion refusal already did, so the mapping above can read them. Messages are unchanged.DataSource.uploadFile/uploadFilesandFileUploadResultare untouched.packages/qa/dogfood/test/data-objectstack-upload-route-38163.dogfood.test.ts: the real-stack pin.packages/qa/dogfood/package.jsongains one devDependency,@object-ui/data-objectstack(workspace:*), andpnpm-lock.yamlgains only that importer entry, written bypnpm install. With that, the pin resolves the adapter, the dogfood closure builds it, and the dogfood test hash follows adapter changes.packages/qa/dogfood/vitest.config.tsgains the one anchored aliascheck:test-source-aliasprescribes, so the pin resolves the adapter's SOURCE in this checkout and not its last build. The dogfood package is private, so it needs no changeset.Tests
uploadTransport-37506.test.tsis updated, because its fake server now answers 404 on/api/data/RESOURCE/uploadas the real one does. The data-objectstack:上传文件和 metadata-client 绕过注入的 fetch,纯令牌会话下被当匿名(接 #37225) #37506 pins keep their meaning: injected fetch, bearer on every request, connection state unchanged. A new top-level describe for data-objectstack 的 uploadFile/uploadFiles 发往一条服务端不存在的路由,上传必然失败(404/405) #38163 checks that no request reaches the unserved route, the exact three-step sequence per file, therecordIdmapping and result, the default scope withoutrecordId, the refusal offieldNameandmetadatawith zero requests, token-only signing with no token on a foreign presigned URL,UPLOAD_ERRORcode, status and serverCode, the partial-batch report, progress, and presigned URLs spelled protocol-relative (//host), slash-backslash and double-backslash getting no token while the presign and complete requests keep it. Ablation, run after the commit: with the previous string check restored, the slash-backslash case fails (1 of 15). The double-backslash case already got no token under that check. With the origin comparison removed, all three spellings and the cross-origin case fail (4 of 15). After restoring, git status is clean.index.tsrestored on disk, the file reported 12 of 12 failed. With the fix restored, it reported 21 of 21 passed (this file plusobjectstack-upload-scope-12055.test.ts).type-checkexited 0, both on 95e3f9f.baseUrlis a bare origin, so no path rule applies), first measured on head 9725c42, resolving the adapter source through the alias (the dependency is declared, and no link was made by hand). The stack isbootStackwithStorageServicePlugin, the attachments fixture and a bearer-only session.uploadFilewith arecordId(token only) anduploadFiles(host bearer fetch) pass 2 of 2. They assert committedsys_filerows, thesys_attachmentrow with itsattachmentId, and that no request reached an unserved upload path. Ablation: with the baseindex.tsrestored on disk (the file shows the old route twice), both tests fail withUPLOAD_ERROR"Not found", the server's 404. Aftergit checkout HEAD, git status is clean and both pass again. The dogfoodtypecheckexits 0.Acceptance notes
README.md(File Uploads) does not describeuploadFile/uploadFiles, and it is outside the claimed surface. No sentence in it became false.Verification
Read first:
index.ts, atuploadThroughStorageandstorageUploadFetch(where the token goes, and which URLs get it), thenuploadFiles(what a partial batch reports).Two-minute check: run
pnpm --dir ui exec vitest run packages/data-objectstack/src/uploadTransport-37506.test.ts. Expected: 15 passed.Local gates on head 95e3f9f
node scripts/pm/dispatch-gates.mjs --commandsderived 87 families over the 8 changed paths, and all 87 exited 0,check:test-source-aliasincluded. The--ranreconciliation reported: 87 derived, 87 run, 0 NOT-MEASURED.overlap-checkreported clean: origin/main, #38192 (which shares the dogfoodpackage.json) and #38284 (which sharespnpm-lock.yaml) all merge cleanly. All other CI families are left to the PR's check-runs.Generated by Claude Code